package com.gome.entitiy;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

@Data
@TableName("sys_ryxx")
@NoArgsConstructor
@AllArgsConstructor

public class Ryxx implements UserDetails,Serializable {

    private static final long serialVersionUID = -8620422580073626211L;
    @TableId
    private String n_id;
    @NotBlank(message = "登录帐号不能为空")
    private String oc_loginname;
    @NotBlank(message = "登录密码不能为空")
    private String oc_password;
    private String oc_czy;
    private Date dt_czrq;
    private String oc_yxbz;
    @TableField(exist =false)
    Collection<GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return oc_password;
    }

    @Override
    public String getUsername() {
        return oc_loginname;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}
